#ifndef _SRC_MQTT_PACKAGE_H_
#define _SRC_MQTT_PACKAGE_H_

#include "Entity.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief mqtt connect 打包
 * @param entity
 * @param pkt
 * @param pktLen
 * @param prop
 * @return
 */
int32_t mqttConnectPkt(MQTTEntity *entity, uint8_t **pkt, uint32_t *pktLen, ConnectProperty *prop);
/**
 * @brief 写入通用属性
 * @param pos
 * @param index
 * @param generalProperty
 * @param propertyLen
 * @param propertyLenOffset
 */
void writeGeneralProp(uint8_t *pos, uint32_t *index, GeneralProperty *generalProperty, uint8_t *propertyLen,uint8_t propertyLenOffset);
/**
 * @brief 编码消息剩余长度
 * @param input
 * @param output
 * @param outputIdx
 */
void encodeRemainLen(uint32_t input, uint8_t *output, uint32_t *outputIdx);
/**
 * @brief 设置UTF-8 编码数据
 * @param input
 * @param inputLen
 * @param output
 */
void setUtf8EncodedString(uint8_t *input, uint16_t inputLen, uint8_t *output);
/**
 * @brief 按照整形读取数据
 * @param input
 * @param remainlen
 * @param offset
 * @return
 */
int32_t readVariableByteInterger(uint8_t *input, uint32_t *remainlen, uint8_t *offset);
/**
 * @brief 解析publish 属性
 * @param entity
 * @param property
 * @param prop
 * @param propertyLen
 * @param parsedOffset
 * @param remainLen
 * @return
 */
int32_t parsePublishProperties(MQTTEntity *entity, uint8_t *property,PubProperty *prop, uint32_t *propertyLen, uint8_t *parsedOffset, uint32_t remainLen);

/**
 * @brief 解析connect ack 属性
 * @param entity
 * @param property
 * @param prop
 * @param remainLen
 * @return
 */
int32_t parseConAckProperties(MQTTEntity *entity, uint8_t *property, ConnAckProperty *prop, uint32_t remainLen);
/**
 * @brief 解析通用属性
 * @param mqtt_handle
 * @param property
 * @param prop
 * @param propertyLen
 * @param offset
 * @param len
 * @return
 */
int32_t parseGeneralProperties(MQTTEntity *mqtt_handle, uint8_t *property,GeneralProperty *prop, uint32_t *propertyLen, uint8_t *offset, uint32_t len);



#ifdef __cplusplus
}
#endif
#endif //_SRC_MQTT_PACKAGE_H_
